$(function () {

    $(".changeType").click(function () {
       var businessId = $(this).attr("businessId");
        var serviceProviderType = $(this).attr("serviceProviderType");
        var qa = serviceProviderType == 20?"确定要切换到普通服务商？":"确定要切换到付费服务商？";
        if (confirm(qa)) {
            var type;
            if(serviceProviderType == 20){
                type = 10;
            }else {
                type = 20;
            }
            var serviceInfoVo = {};
            serviceInfoVo.id = businessId;
            serviceInfoVo.serviceProviderType = type;
            $.ajax({
                url: "/serviceProvider/changeType.action",
                type: "POST",
                data:JSON.stringify(serviceInfoVo),
                contentType : 'application/json;charset=utf-8',
                dataType: "json",
                success: function (data) {
                    if (data.success) {
                        window.location.href = '/serviceProvider/manageType.action';
                    } else {
                        alert("切换失败！请联系系统管理员。");
                    }
                }
            });
        }
    });

})